<?php

include_once("phpmailer.inc.php");

define('GUSER', '@gmail.com'); // Gmail username
define('GPWD', ''); // Gmail password

define('SMTPUSER', 'you@yoursmtp.com'); // sec. smtp username
define('SMTPPWD', 'password'); // sec. password
define('SMTPSERVER', 'smtp.yoursmtp.com'); // sec. smtp server

function smtpmailer($to, $from, $from_name, $subject, $body, $is_gmail = true) { 
	global $error;
	$mail = new phpmailer();
	$mail->IsSMTP();
	$mail->SMTPAuth = true; 
	$mail->Mailer = true; 
	if ($is_gmail) {
		$mail->SMTPSecure = 'ssl'; 
		$mail->Host = 'smtp.gmail.com';
		$mail->Port = 465;  
		$mail->Username = GUSER;  
		$mail->Password = GPWD;   
	} else {
		$mail->Host = SMTPSERVER;
		$mail->Username = SMTPUSER;  
		$mail->Password = SMTPPWD;
	}        
	//$mail->SetFrom($from, $from_name);
	//$mail->Subject = $subject;
	//$mail->Body = $body;
	//$mail->AddAddress($to);
 $mail->AddAddress($to);
 $mail->From = $from;
 $mail->FromName = $from_name;
 $mail->Subject = $subject;
 $mail->Body = $body;
	if(!$mail->Send()) {
		$error = 'Mail error: '.$mail->ErrorInfo;
  echo $error;
		return false;
	} else {
		$error = 'Message sent!';
		return true;
	}
}


?>
